<template>
  <elm-page-tb style="width: calc(100% - 1px);height: calc(100% - 1px);" :splite="false" :splite-show="false">
    <template #top>
      <el-input placeholder="请查询输入内容" prefix-icon='el-icon-search' size="mini" style="width: 250px;" v-model="postData.name" clearable></el-input>
      <right>
        <el-button-group>
          <el-button icon="el-icon-search" size="mini" @click="treebinding()">查询</el-button>
          <elm-open-button url="craft_edit" icon="el-icon-edit" title="新增" width="700" height="450" :data="{ pid: '0', pd_code: postData.pd_code }" v-if="!is_show">新增</elm-open-button>
        </el-button-group>
      </right>
    </template>
    <elm-table-tree url="/business/plm/product/craft/GetTree" :post-data="postData" :default-expand-all="true" :page-size="50" height="100%">
      <el-table-column type="index" label="序号" width="60px" align="center"></el-table-column>
      <el-table-column prop="name" label="名称" header-align="center"></el-table-column>
      <el-table-column prop="sys_code_key" label="编号" align="center" width="100px"></el-table-column>
      <el-table-column prop="type" label="类型" align="center" width="80px"></el-table-column>
      <el-table-column prop="remark" label="备注" header-align="center"></el-table-column>
      <el-table-column prop="sort" label="顺序" width="80px" align="center"></el-table-column>
      <el-table-column fixed="right" label="操作" width="200px" align="center" v-if="!is_show">
        <template v-slot="scope">
          <elm-open-button url="craft_edit" :title="'编辑[' + scope.row.name + ']'" width="700" height="450" :data="{ model: scope.row }" type="text">编辑</elm-open-button>
          <elm-open-button url="craft_edit" :title="'新增[' + scope.row.name + ']的下级'"  width="700" height="450"
                           :data="{ pid: scope.row.id , pd_code: postData.pd_code }" type="text">新增下级</elm-open-button>
          <el-button type="text" size="mini" @click="deleteData(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </elm-table-tree>
  </elm-page-tb>
</template>

<script>
export default {
  extends: elmVueBase,
  data() {
    return {
      postData: { name: null , pd_code: elm.dialog.request.pd_code },
      is_show:elm.dialog.request.is_show
    }
  },
  async created() {
  },
  methods: {
    async deleteData(data) {
      await this.delete('/business/plm/product/craft/Delete', { id: data.id });
      this.treebinding();
    }
  }
}
</script>

<style scoped>
</style>